package gameEngine.agents.observationSystem;

import gameEngine.agents.observationSystem.samples.Sample;

import java.util.Stack;
/**
 * @author Vladimir && Alon
 * 
 * Every object of this class is have observations of some agent
 * from the start of the game 
 * 
 * Every round that this specific player is play, a new sample
 * is added to the stack
 */
public class AgentsObservation {
	
	// the id of the player that is observed
	private int ID;
	
	// container of observations for specific player
	private Stack <Sample> observations;
	
	/**
	 * CTOR
	 * @param id
	 */
	AgentsObservation(int id)
	{
		this.ID = id;
		observations = new Stack<Sample>();
	}

	/**
	 *  get a index and return an ObservationData in this index
	 *  from the container
	 * @param ndx
	 * @return Sample
	 */
	public Sample getSample(int ndx)
	{
		return observations.get(ndx);
	}
	
	/**
	 *  Return the last sample
	 *  If the stack is empty return null
	 * 	@return Sample
	 */
	public Sample getLastSample()
	{
		Sample lastSample;
		try{
			lastSample = observations.peek();
		}
		//case the the stack is empty
		catch (Exception e) {
			lastSample = null;
		}
		
		return lastSample;
	}
	
	/** 
	 * 	get the all collection of observations
	 *  from the container
	 *  @return Stack <Sample>
	 */ 
	public Stack <Sample> getAllSamples()
	{
		return observations;
	}
	
	/**
	 * add  a sample to the collection
	 * @param sample
	 */
	public void  addSample(Sample sample)
	{
		observations.push(sample);
	}	
	
	/**
	 * @return size of the stack
	 */
	public int getNumOfObservations()
	{
		return observations.size();
	}
	
	
	public int getID() {
		return ID;
	}
		
}
